If you set stdout to be unbuffered:
setvbuf(stdout,NULL,_IONBF,0);
Would there be any reason to use fflush(stdout)?
Thanks you guys :]
If you set stdout to be unbuffered:
setvbuf(stdout,NULL,_IONBF,0);
Would there be any reason to use fflush(stdout)?
Thanks you guys :]
For unix this does just what you'd expect - outputs a few characters then pauses 1 second.
This means extra work for the kernel, by the way.
.. fflush(stdout) is pointless in this context. Dunno for sure what Windows does...Code:#include <stdio.h> int main() { setvbuf(stdout,NULL,_IONBF,0); for (unsigned int i=0;i<10;i++) { fprintf(stdout,"%d..",i); sleep(1); } fprintf(stdout,"\n"); return 0; }